package cn.yesway.agent.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.yesway.agent.service.SmsService;
import cn.yesway.agent.soap.smssoap.Sms;
import cn.yesway.agent.soap.smssoap.WebShortMessageSoap_PortType;

@Service
public class SmsServiceImpl implements SmsService {
	private static final Logger log = LoggerFactory.getLogger(SmsServiceImpl.class);

	@Autowired
	private WebShortMessageSoap_PortType webShortMessageSoap;

	public boolean sendLongText(String source, String phone, String content, String signature) {
		log.debug("sendLongText Start: {source:" + source + ",phone:" + phone + ",content:" + content + ",signature:" + signature + "}");
		boolean result = false;
		try {
			Sms sms = new Sms();
			sms.setSrc(source);
			sms.setDest(phone);
			sms.setContent(content);
			sms.setLogo(signature);
			sms.setChannle(0);
			int send = webShortMessageSoap.sendText(sms);
			log.debug("sendLongText Send result: " + send);
			if (send == 0) {
				result = true;
			}
		} catch (Exception e) {
			log.error("sendLongText error:", e);
		}
		log.debug("sendLongText End: {result:" + result + "}");
		return result;
	}

}
